package com.example.videoconverter;

import java.io.File;

/**
 * 独立的main方法测试simpleConvertAviToMp4方法
 */
public class SimpleMain {
    
    public static void main(String[] args) {
        VideoConverter converter = new VideoConverter();
        
        // 测试文件路径
        String inputPath = "target/classes/sample_1280x720.avi";
        String outputPath = "target/simple_output.mp4";
        
        try {
            System.out.println("开始AVI转MP4转换...");
            System.out.println("输入文件: " + inputPath);
            System.out.println("输出文件: " + outputPath);
            
            // 检查输入文件
            File inputFile = new File(inputPath);
            if (!inputFile.exists()) {
                System.out.println("错误: 输入文件不存在");
                return;
            }
            
            long startTime = System.currentTimeMillis();
            
            // 调用简化转换方法
            converter.simpleConvertAviToMp4(inputPath, outputPath);
            
            long endTime = System.currentTimeMillis();
            
            // 验证结果
            File outputFile = new File(outputPath);
            if (outputFile.exists()) {
                System.out.println("转换成功!");
                System.out.printf("耗时: %.2f 秒%n", (endTime - startTime) / 1000.0);
                System.out.printf("输出文件大小: %.2f MB%n", outputFile.length() / (1024.0 * 1024.0));
            } else {
                System.out.println("转换失败: 输出文件未生成");
            }
            
        } catch (Exception e) {
            System.out.println("转换过程中发生错误: " + e.getMessage());
            e.printStackTrace();
        }
    }
}